#include "loginpage.h"
#include "ui_loginpage.h"

LoginPage::LoginPage(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::LoginPage)
{
    ui->setupUi(this);

    /*绑定所有按钮的信号到槽函数*/
    QList<QPushButton*> buttonList = this->findChildren<QPushButton*>();
    for(int i = 0;i < buttonList.size();i++)
    {
        connect(buttonList[i],SIGNAL(clicked(bool)),this,SLOT(pushbutton_cb()));
    }
}

LoginPage::~LoginPage()
{
    delete ui;
}

void LoginPage::pushbutton_cb()
{
    QObject* button = sender();
    if(button == ui->pushButton_login)//登录
    {
        MainWindow* mainWindow = new MainWindow();
        mainWindow->show();
        connect(this,SIGNAL(showStudentFormat(QString)),mainWindow,SLOT(showStudentFormat(QString)));
        if(ui->radioButton_student->isChecked())
        {
            emit showStudentFormat(ui->lineEdit_id->text());
        }
        close();
    }
}
